<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>梦幻蛋糕坊</title>
  <style>
    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      font-family: 'Arial', sans-serif;
    }

    body {
      background-color: #f5f5ff;
      padding: 20px;
    }

    .header {
      text-align: center;
      margin-bottom: 30px;
      padding: 20px;
      background: linear-gradient(135deg, #b8c6ff 0%, #e0b0ff 100%);
      color: white;
      border-radius: 8px;
      box-shadow: 0 4px 15px rgba(168, 150, 255, 0.2);
    }

    .cakes-container {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
      gap: 25px;
      margin-bottom: 40px;
    }

    .cake-card {
      background-color: white;
      border-radius: 10px;
      overflow: hidden;
      box-shadow: 0 4px 12px rgba(168, 150, 255, 0.1);
      transition: all 0.3s ease;
      border: 1px solid #e6e6ff;
    }

    .cake-card:hover {
      transform: translateY(-5px);
      box-shadow: 0 8px 20px rgba(168, 150, 255, 0.2);
    }

    .cake-image {
      width: 100%;
      height: 200px;
      object-fit: cover;
      border-bottom: 1px solid #f0f0ff;
    }

    .cake-info {
      padding: 15px;
      background-color: #fafaff;
    }

    .cake-title {
      font-size: 18px;
      margin-bottom: 10px;
      color: #5a5a8a;
    }

    .cake-price {
      color: #8a7bff;
      font-weight: bold;
      margin-bottom: 15px;
    }

    .quantity-control {
      display: flex;
      align-items: center;
      margin-bottom: 15px;
    }

    .quantity-btn {
      width: 30px;
      height: 30px;
      background-color: #f0f0ff;
      border: 1px solid #d6d6ff;
      font-size: 16px;
      cursor: pointer;
      border-radius: 4px;
      color: #7a6bff;
    }

    .quantity-btn:hover {
      background-color: #e6e6ff;
    }

    .quantity-input {
      width: 50px;
      height: 30px;
      text-align: center;
      margin: 0 10px;
      border: 1px solid #d6d6ff;
      border-radius: 4px;
      background-color: #fafaff;
      color: #5a5a8a;
    }

    .add-to-cart {
      width: 100%;
      padding: 10px;
      background: linear-gradient(135deg, #8a7bff 0%, #b88cff 100%);
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      font-weight: bold;
      transition: all 0.3s ease;
    }

    .add-to-cart:hover {
      background: linear-gradient(135deg, #7a6bff 0%, #a87cff 100%);
      box-shadow: 0 4px 10px rgba(138, 123, 255, 0.3);
    }

    .cart-container {
      position: fixed;
      top: 20px;
      right: 20px;
      background-color: white;
      padding: 15px;
      border-radius: 8px;
      box-shadow: 0 4px 15px rgba(168, 150, 255, 0.15);
      z-index: 100;
      border: 1px solid #e6e6ff;
    }

    .cart-count {
      display: inline-block;
      width: 20px;
      height: 20px;
      background: linear-gradient(135deg, #8a7bff 0%, #b88cff 100%);
      color: white;
      border-radius: 50%;
      text-align: center;
      line-height: 20px;
      font-size: 12px;
      margin-left: 5px;
    }

    .cart-items {
      margin-top: 10px;
      max-height: 300px;
      overflow-y: auto;
    }

    .cart-item {
      padding: 8px 0;
      border-bottom: 1px solid #f0f0ff;
      color: #5a5a8a;
    }

    /* 自定义滚动条 */
    .cart-items::-webkit-scrollbar {
      width: 6px;
    }

    .cart-items::-webkit-scrollbar-track {
      background: #f5f5ff;
    }

    .cart-items::-webkit-scrollbar-thumb {
      background-color: #c6b6ff;
      border-radius: 3px;
    }
  </style>
</head>
<body>
<div class="header">
  <h1>梦幻蛋糕坊</h1>
  <p>用梦幻色彩点缀您的甜蜜时光</p>
</div>

<div class="cart-container">
  <h3 style="color: #5a5a8a;"><a href="cartServlet?opt=show">购物车</a> <span id="cartTotal" class="cart-count">0</span></h3>
  <div id="cartItems" class="cart-items"></div>
</div>

<div class="cakes-container">
  <!-- 蛋糕1 -->
  <div class="cake-card">
    <form action="cartServlet?opt=add" method="post">
      <input type="hidden" id="id" name="id" value="cake1">
      <input type="hidden" id="name" name="name" value="香草奶油蛋糕">
      <input type="hidden" id="price" name="price" value="128">
      <input type="hidden" id="imageUrl" name="imageUrl"
             value="https://img.freepik.com/free-photo/delicious-vanilla-cake_144627-8850.jpg">
      <img  src="https://img.freepik.com/free-photo/delicious-vanilla-cake_144627-8850.jpg" alt="香草奶油蛋糕" class="cake-image">
      <div class="cake-info">
        <h3 class="cake-title"  >香草奶油蛋糕</h3>
        <p class="cake-price" >¥128</p>
        <div class="quantity-control">

          <input type="number" id="cake1" name="num" class="quantity-input" value="1" min="1">

        </div>
        <button type="submit" class="add-to-cart" >加入购物车</button>
      </div>
    </form>
  </div>

  <!-- 蛋糕2-->
  <div class="cake-card">
    <form action="cartServlet?opt=add" method="post">
      <input type="hidden"  name="id" value="cake2">
      <input type="hidden"  name="name" value="巧克力熔岩蛋糕">
      <input type="hidden" name="price" value="158">
      <input type="hidden" name="imageUrl"
             value="https://img.freepik.com/free-photo/chocolate-cake_144627-8998.jpg">
      <img src="https://img.freepik.com/free-photo/chocolate-cake_144627-8998.jpg" alt="巧克力熔岩蛋糕" class="cake-image">
      <div class="cake-info">
        <h3 class="cake-title">巧克力熔岩蛋糕</h3>
        <p class="cake-price">¥158</p>
        <div class="quantity-control">

          <input type="number" name="num"  class="quantity-input" value="1" min="1">

        </div>
        <button class="add-to-cart" type="submit">加入购物车</button>
      </div>
    </form>
  </div>
</div>
</body>
</html>